1 <Window x:Class="MainWindow"
2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4 xmlns:local="clr-namespace:VBWPFAnimationWhenDataChanged"
5 Title="MainWindow" Height="473" Width="632" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit">
8 <Style x:Key="cellStyle" TargetType="{x:Type my:DataGridCell}">
10 <!--When Binding target is updated, trigger the animation-->
11 <EventTrigger RoutedEvent="Binding.TargetUpdated">
14 <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" AutoReverse="True"
15 To="Red" Duration="0:0:2"/>
16 <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" AutoReverse="True"
17 To="Transparent" BeginTime="0:0:2" Duration="0:0:2"></ColorAnimation>
25 <my:DataGrid ItemsSource="{Binding .}"
28 AutoGenerateColumns="True"
29 IsSynchronizedWithCurrentItem="True">
35 VerticalAlignment="Bottom"
36 BorderBrush="Chocolate"
37 BorderThickness="1.0">
38 <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="103" Width="586">
40 HorizontalAlignment="Left"
41 HorizontalContentAlignment="Right"
44 VerticalAlignment="Top"
45 Width="82">Name:</Label>
46 <Label HorizontalAlignment="Left"
47 HorizontalContentAlignment="Right"
50 Width="80">Job:</Label>
54 VerticalAlignment="Top"
55 Text="{Binding FirstName,
57 UpdateSourceTrigger = PropertyChanged,
58 NotifyOnSourceUpdated=True}"/>
59 <TextBox Margin="107,44,7,31"
61 Text="{Binding LastName, Mode = TwoWay,
62 UpdateSourceTrigger = PropertyChanged,
63 NotifyOnSourceUpdated=True}" />
69 VerticalAlignment="Bottom">Click the button in the bottom, and then edit in the following TextBoxes:</Label>
72 Name="btnHookupAnimation"
73 VerticalAlignment="Bottom"
74 Click="btnHookupAnimation_Click">Hook up Animation</Button>